$.extend($.fn.validatebox.defaults.rules, {
	midLength : {
		validator : function(value, param) {
			return value.length >= param[0] && value.length <= param[1];
		},
		message : ''
	}
});

$.extend($.fn.validatebox.defaults.rules, {
	loginName : {
		validator : function(value, param) {
			reg = /^[a-zA-z]+[a-zA-Z0-9]*$/;
			if (!reg.test(value)) {
				return false;
			}

			return value.length >= param[0] && value.length <= param[1];
		},
		message : "登录名只能包含字母和数字，以字母开头，长度在3和9个字符之间"
	}
});

$.fn.tree.defaults.loadFilter = function(data, parent) {
	var opt = $(this).data().tree.options;
	var idFiled, textFiled, parentField;
	if (opt.parentField) {
		idFiled = opt.idFiled || 'id';
		textFiled = opt.textFiled || 'text';
		parentField = opt.parentField;
		var i, l, treeData = [], tmpMap = [];
		for (i = 0, l = data.length; i < l; i++) {
			tmpMap[data[i][idFiled]] = data[i];
		}
		for (i = 0, l = data.length; i < l; i++) {
			if (tmpMap[data[i][parentField]]
					&& data[i][idFiled] != data[i][parentField]) {
				if (!tmpMap[data[i][parentField]]['children'])
					tmpMap[data[i][parentField]]['children'] = [];
				data[i]['text'] = data[i][textFiled];
				tmpMap[data[i][parentField]]['children'].push(data[i]);
			} else {
				data[i]['text'] = data[i][textFiled];
				treeData.push(data[i]);
			}
		}
		return treeData;
	}
	return data;
};